﻿using Microsoft.EntityFrameworkCore;
using T.S.BaseData.Domain.Entity;

namespace T.S.BaseData.Infrastructure
{
    public class MyDbContext : DbContext
    {
        public MyDbContext(DbContextOptions options) : base(options)
        {
        }


        /// <summary>
        /// 养殖
        /// </summary>
        public DbSet<CultivationInfo> CultivationInfo { get; set; }

        /// <summary>
        /// 养殖企业
        /// </summary>
        public DbSet<EnterpriseInfo> EnterpriseInfo { get; set; }

        /// <summary>
        /// 商品
        /// </summary>
        public DbSet<GoodsInfo> GoodsInfo { get; set; }

        /// <summary>
        /// 图片
        /// </summary>
        public DbSet<Img> Img { get; set; }

        /// <summary>
        /// 深加工
        /// </summary>
        public DbSet<Processing> Processing { get; set; }

        /// <summary>
        /// 深加工企业
        /// </summary>
        public DbSet<ProcessingCompany> ProcessingCompany { get; set; }

        /// <summary>
        /// 屠宰
        /// </summary>
        public DbSet<Slaughter> Slaughter { get; set; }

        /// <summary>
        /// 屠宰企业
        /// </summary>
        public DbSet<SlaughteringEnterprises> SlaughteringEnterprises { get; set; }

        /// <summary>
        /// 用户
        /// </summary>
        public DbSet<User> User { get; set; }

        /// <summary>
        /// 商品基本信息
        /// </summary>
        public DbSet<BasicInfo> BasicInfo { get; set; }


        /// <summary>
        /// 保健
        /// </summary>
        public DbSet<Health> Health { get; set; }












        //软删除过滤
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.Entity<BasicInfo>().HasQueryFilter(x=>!x.IsDelete);
            modelBuilder.Entity<CultivationInfo>().HasQueryFilter(x => !x.IsDelete);
            modelBuilder.Entity<EnterpriseInfo>().HasQueryFilter(x => !x.IsDelete);
            modelBuilder.Entity<GoodsInfo>().HasQueryFilter(x => !x.IsDelete);
            modelBuilder.Entity<Health>().HasQueryFilter(x => !x.IsDelete);
            modelBuilder.Entity<Img>().HasQueryFilter(x => !x.IsDelete);
            modelBuilder.Entity<Processing>().HasQueryFilter(x => !x.IsDelete);
            modelBuilder.Entity<ProcessingCompany>().HasQueryFilter(x => !x.IsDelete);
            modelBuilder.Entity<Slaughter>().HasQueryFilter(x => !x.IsDelete);
            modelBuilder.Entity<SlaughteringEnterprises>().HasQueryFilter(x => !x.IsDelete);
        }

    }
}
